Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
26 lines (21 loc) · 530 Bytes

10.1.5 - Coroutine::getuid.md

File metadata and controls

26 lines (21 loc) · 530 Bytes

Coroutine::getuid

获取当前协程的ID。函数原型

int function Swoole\Coroutine::getuid();

协程task的结构是:

struct _coro_task
{
    int cid; //协程ID
    /**
     * user coroutine
     */
    zval *function;
    time_t start_time;
    void (*post_callback)(void *param);
    void *post_callback_params;
};
  • 返回当前协程ID,是一个由0增长的长整型。
  • 服务器被请求周期内,获取到的数值是固定的不变的,可用来作为一些全局变量下标使用